package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.List;


/**
 * The persistent class for the INSTOCK database table.
 * 
 */
@Entity
@NamedQuery(name="Instock.findAll", query="SELECT i FROM Instock i")
public class Instock implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="INSTOCK_INSTOID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="INSTOCK_INSTOID_GENERATOR")
	private long instoid;

	@Column(name="PURCHASE_ID")
	private BigDecimal purchaseId;

	//bi-directional many-to-one association to Stock
	@ManyToOne
	@JoinColumn(name="STOCK_ID")
	private Stock stock;

	//bi-directional many-to-one association to InstockDetail
	@OneToMany(mappedBy="instock")
	@JSONField(serialize=false)
	private List<InstockDetail> instockDetails;

	public Instock() {
	}

	public long getInstoid() {
		return this.instoid;
	}

	public void setInstoid(long instoid) {
		this.instoid = instoid;
	}

	public BigDecimal getPurchaseId() {
		return this.purchaseId;
	}

	public void setPurchaseId(BigDecimal purchaseId) {
		this.purchaseId = purchaseId;
	}

	public Stock getStock() {
		return this.stock;
	}

	public void setStock(Stock stock) {
		this.stock = stock;
	}

	public List<InstockDetail> getInstockDetails() {
		return this.instockDetails;
	}

	public void setInstockDetails(List<InstockDetail> instockDetails) {
		this.instockDetails = instockDetails;
	}

	public InstockDetail addInstockDetail(InstockDetail instockDetail) {
		getInstockDetails().add(instockDetail);
		instockDetail.setInstock(this);

		return instockDetail;
	}

	public InstockDetail removeInstockDetail(InstockDetail instockDetail) {
		getInstockDetails().remove(instockDetail);
		instockDetail.setInstock(null);

		return instockDetail;
	}

}